package com.xjgzinfo.usdp.service.impl;

import com.xjgzinfo.usdp.domain.BladeVisualMap;
import com.xjgzinfo.usdp.repository.BladeVisualMapRepository;
import com.xjgzinfo.usdp.service.BladeVisualMapService;
import com.xjgzinfo.usdp.service.dto.BladeVisualMapDTO;
import com.xjgzinfo.usdp.service.mapper.BladeVisualMapMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Optional;

/**
 * Service Implementation for managing {@link BladeVisualMap}.
 */
@Service
@Transactional
public class BladeVisualMapServiceImpl implements BladeVisualMapService {

    private final Logger log = LoggerFactory.getLogger(BladeVisualMapServiceImpl.class);

    private final BladeVisualMapRepository bladeVisualMapRepository;

    private final BladeVisualMapMapper bladeVisualMapMapper;

    public BladeVisualMapServiceImpl(BladeVisualMapRepository bladeVisualMapRepository, BladeVisualMapMapper bladeVisualMapMapper) {
        this.bladeVisualMapRepository = bladeVisualMapRepository;
        this.bladeVisualMapMapper = bladeVisualMapMapper;
    }

    @Override
    public BladeVisualMapDTO save(BladeVisualMapDTO bladeVisualMapDTO) {
        log.debug("Request to save BladeVisualMap : {}", bladeVisualMapDTO);
        BladeVisualMap bladeVisualMap = bladeVisualMapMapper.toEntity(bladeVisualMapDTO);
        bladeVisualMap = bladeVisualMapRepository.save(bladeVisualMap);
        return bladeVisualMapMapper.toDto(bladeVisualMap);
    }

    @Override
    @Transactional(readOnly = true)
    public Page<BladeVisualMapDTO> findAll(Pageable pageable) {
        log.debug("Request to get all BladeVisualMaps");
        return bladeVisualMapRepository.findAll(pageable)
                .map(bladeVisualMapMapper::toDto);
    }


    @Override
    @Transactional(readOnly = true)
    public Optional<BladeVisualMapDTO> findOne(Long id) {
        log.debug("Request to get BladeVisualMap : {}", id);
        return bladeVisualMapRepository.findById(id)
                .map(bladeVisualMapMapper::toDto);
    }

    @Override
    public void delete(Long id) {
        log.debug("Request to delete BladeVisualMap : {}", id);
        bladeVisualMapRepository.deleteById(id);
    }
}
